package org.example.basic.lambda.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 各种toList案例
 * @author songyafei
 */
public class LambdaToAllList {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>(Arrays.asList("","A",null,"C"));
        //集合中不允许有null，否则null 指针
//        List<String> collect = list.stream().collect(Collectors.toUnmodifiableList());
        //运行为空 "" or null
        List<String> collect1 = list.stream().collect(Collectors.toList());
//        collect.forEach(System.out::println);
//        collect1.forEach(System.out::println);

        System.out.println("----------------------------------------------------");
        //null or "" 不过滤
        Set<String> collect = list.stream().collect(Collectors.toSet());
//        collect.forEach(System.out::println);
        //将元素连接在一起
        String cjoin = list.stream().collect(Collectors.joining());
        System.out.println(cjoin);
        System.out.println(cjoin.codePoints());
        System.out.println(cjoin.codePointCount(0,cjoin.length()));
        System.out.println(cjoin.endsWith("n"));



    }
}
